<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type='text/javascript' src='res/jquery-2.2.4.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='res/jquery.qrcode.min.js' charset='utf-8'></script>
    <title>发起提现演示界面</title>
</head>
<body>
<div style="width: 375px; height: 600px; margin: 0 auto; padding-top: 30px; border: 1px solid #ccc; text-align: center;">
    <div  class="qrCodeBox">
        <div>
            <textarea id="resultBox" style="height: 260px; width: 260px; margin: 0 auto;" readonly></textarea>
        </div>
        <div id="orderNo" style="padding: 10px 0;">
        </div>
        <div id="msgBox" style="padding: 10px 0; color: red;">
        </div>
    </div>

    <div>
        提现金额: <input type="text" id="orderAmount" value="1" /><br />
        下游商户号: <input type="text" id="merSubCode" value="8001001" /><br />
        银行名称: <input type="text" id="bankName" value="瑞士银行" /><br />
        银行地址: <input type="text" id="bankAddress" value="瑞士中央支行" /><br />
        银行卡号: <input type="text" id="bankCard" value="888888888888" /><br />
        持卡人名称: <input type="text" id="customerName" value="张三" /><br />
        持卡人电话: <input type="text" id="customerPhone" value="18888888888" /><br />
        <button onclick="applyForWithdrawal()" style="height: 50px; width: 120px;">发起提现</button>
        <button onclick="reload()" style="height: 50px; width: 120px; margin-left: 20px;">刷新</button>
    </div>


    <div>
        订单支付状态: <span id="orderStatus"></span>
    </div>
</div>
</body>
<script>

    // 订单号
    var orderNo;

    /**
     * 发起提现
     */
    function applyForWithdrawal() {

        $("#resultBox").html("");
        $("#orderNo").html("");
        $("#msgBox").html("");

        var amount = $("#orderAmount").val();

        $.ajax({
            url: "withdrawal/applyForWithdrawal",
            type: "POST",
            data: {
                "orderAmount": amount,
                "merSubCode": $("#merSubCode").val(),
                "bankName": $("#bankName").val(),
                "bankAddress": $("#bankAddress").val(),
                "bankCard": $("#bankCard").val(),
                "customerName": $("#customerName").val(),
                "customerPhone": $("#customerPhone").val()
            },
            success: function(result) {
                $("#msgBox").html(result.msg);
                if (result.status === true) {
                    $("#orderNo").html("订单号:" + result.orderNo + "，金额:"+amount+"元");
                    // 生成二维码
                    $("#resultBox").text(JSON.stringify(result));
                    // 记录订单号
                    orderNo = result.orderNo;
                }
            }
        });
    }


    function reload() {
        window.location.reload();
    }
</script>
</html>